home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 4 / Mac Giga-ROM 4.0 - 1993.toast / FILES / HYP / R-S / Sound Scripter / stack_-1.xml < prev    next >
Encoding:
Extensible Markup Language  |  1989-02-26  |  12.0 KB  |  16 lines

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
  3. <stack>
  4.     <name>in</name>
  5.     <id>-1</id>
  6.     <cardCount>15</cardCount>
  7.     <cardID>2424</cardID>
  8.     <listID>8649</listID>
  9.     <cantModify><false /></cantModify>
  10.     <cantDelete><true /></cantDelete>
  11.     <cantAbort><false /></cantAbort>
  12.     <cardSize>
  13.         <width>512</width>
  14.         <height>342</height>
  15.     </cardSize>
  16.     <script>--‚͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂͂Ķ
  17. --
  18. --            Sound Scripter    copyright 1988 by Tim Lyons
  19. --
  20. --    Please feel free to use and modify this stack as you see fit but
  21. -- leave this notice in place. If you make changes and redistribute the
  22. -- altered version, then note which changes are your contribution, so
  23. -- that the user knows to whom to complain about which feature.
  24. --    I am not asking for money, and you may not charge others for my
  25. -- work. If you find this stack useful, then drop me a line. Pass along
  26. -- any complaints, suggestions, clever tricks, or improvements you have
  27. -- made to my code.
  28. --                                                 Tim Lyons
  29. --                                                 9211 Palmer rd.
  30. --                                                 North East, PA 16429
  31. --
  32. --…………………………………………………………………………………………………………………………………………………………………………………………
  33. --
  34. --
  35. --
  36. --      This is my first major stack created from scratch. I started
  37. -- writing it as an exercise to teach myself HyperTalk while I was
  38. -- reading Danny Goodman‚Äôs book. I had enough fun with it that I kept
  39. -- working on it while I read the draft version of HyperCard Script
  40. -- Language Guide.
  41. --      It may not show now, but at one time, this script was fairly
  42. -- straightforward; however, as I added frills and error checking,
  43. -- things got out of control. Parts of this script date back to my
  44. -- earliest efforts. As I became more familiar with how things worked,
  45. -- I backed up and reworked much, but not all, of the earlier sections.
  46. -- Unfortunately, it has become so complex that I‚Äôm reluctant to monkey
  47. -- around with things that are working. I hope that it won‚Äôt be too
  48. -- confusing to be useful.
  49. --
  50. --
  51. --…………………………………………………………………………………………………………………………………………………………………………………………
  52.  
  53. on openStack
  54. global stackName
  55. put the name of this stack into stackName
  56. startingUp
  57. end openStack
  58.  
  59. on resume
  60. startingUp
  61. send "startUp" to card "piano keyboard"
  62. end resume
  63.  
  64. on startingUp
  65. global voice,theTempo,duration,durationButton,scriptMode
  66. global menu1,menu2,rebuildPopUpMenu
  67. global modifierButton,tripletCount,priorUserLevel,startingUserLevel
  68. push recent card
  69. get the userlevel
  70. put it into startingUserLevel
  71. set the userlevel to 5
  72. if the version ‚â• 1.1 then set textArrows to true
  73. set the rect of card field "welcomeField"¬¨
  74. of card "piano keyboard" to 3,23,509,128
  75. set the visible of card field "welcomeField"¬¨
  76. of card "piano keyboard" to true
  77. setDefaultValues
  78. put true into rebuildPopUpMenu
  79. put "Harpsichord" into voice
  80. put 100 into theTempo
  81. put "w" into duration
  82. put "whole" into durationButton
  83. set the lockscreen to true
  84. buildGoToFileMenu
  85. go to card "piano keyboard"
  86. end startingUp
  87.  
  88.  
  89. on setDefaultValues
  90. global modifierButton,tripletCount,scriptMode
  91. global copyPromptCount,firstCopyCardPrompt
  92. set the visible of card button "Sound Scripter" ¬¨
  93. of card "helpCard7" to false
  94. put true into firstCopyCardPrompt
  95. put 0 into copyPromptCount
  96. put "none" into modifierButton
  97. put 0 into tripletCount
  98. put "newLine" into scriptMode
  99. end setDefaultValues
  100.  
  101. on closeStack
  102. shuttingDown
  103. end closeStack
  104.  
  105. on suspend
  106. shuttingDown
  107. end suspend
  108.  
  109. on shuttingDown
  110. global menu1,menu2
  111. global priorUserLevel,startingUserLevel
  112. global durationButton,modifierButton
  113. deleteMyMenus
  114. get the userLevel
  115. put it into priorUserLevel
  116. set the userLevel to 5
  117. get the freeSize of this stack
  118. if it > 1024 * 2 then doMenu "Compact Stack"
  119. set the userLevel to priorUserLevel
  120. set the userlevel to startingUserLevel
  121. set the hilite of card button durationButton ¬¨
  122. of card "piano keyboard" to false
  123. set the hilite of card button modifierButton ¬¨
  124. of card "piano keyboard" to false
  125. put empty into card field "tempoField" of card "piano keyboard"
  126. put empty into bkgnd field "noteFeedback" of card "piano keyboard"
  127. put empty into card field "changeVoiceField" of card "piano keyboard"
  128. end shuttingDown
  129.  
  130. on buildMyMenus
  131. global menu1,menu2
  132. set the lockScreen to true
  133. put NewMenu("Script","Play this script/[","Play selection",¬¨
  134. "Play last line/]","Stop playing/.","(-","Save to file‚Ķ/S",¬¨
  135. "New script‚Ķ/A","Erase this script/E","(-","Chromatic Scale‚Ķ",¬¨
  136. "(-","Start New Line/\",¬¨
  137. "Insert Empty Line/L","Erase Last Line/D") into menu1
  138. if menu1 is 0 then answer("Unable to make menu 'Script'") with "Drat"
  139. send upDateMenu to card field "buildGTFMenuField"¬¨
  140. of card "piano keyboard"
  141. if menu2 is 0 then answer("Unable to make menu 'Go To File'") with "Drat"
  142. end buildMyMenus
  143.  
  144. on deleteMyMenus
  145. global menu1,menu2
  146. set the lockScreen to true
  147. put DeleteMenu(menu1) into menu1  --  clearing global for safety
  148. put DeleteMenu(menu2) into menu2
  149. end deleteMyMenus
  150.  
  151.  
  152. on buildGoToFileMenu
  153. global cardCount
  154. put "on upDateMenu"&return into temp
  155. put "global menu2"&return after temp
  156. put "put NewMenu("&quote&"Go To File"&quote after temp
  157. put cardsInBkgnd("SavedScriptsBkgnd") into cardCount
  158. if cardCount > 16 then put 16 into cardCount
  159. repeat with i = 1 to cardCount - 1
  160. get the short name of card i + 1 of bkgnd "SavedScriptsBkgnd"
  161. put ","&quote&it&quote after temp
  162. end repeat
  163. put ") into menu2"&return&"end upDateMenu" after temp
  164. set the script of card field "buildGTFMenuField" ¬¨
  165. of card "piano keyboard" to temp
  166. end buildGoToFileMenu
  167.  
  168.  
  169. function cardsInBkgnd bkgndName -- There‚Äôs probably a simpler way to do
  170. --                               this, but I didn‚Äôt think of it, so
  171. --                               the script ends up running around
  172. --                               in circles while building the
  173. --                               "Go To File" menu. I don‚Äôt like the
  174. --                               idea, but I don‚Äôt know how else to
  175. --                               find out the names of all the cards
  176. --                               of a specific background. Anybody out
  177. --                               there know a better way?
  178. global menu1,menu2
  179. hide the message box
  180. put 0 into theCount
  181. set the lockscreen to true
  182. get the short name of first card of bkgnd bkgndName
  183. put it into name1
  184. go to card name1
  185. put empty into cardName
  186. repeat until cardName = name1
  187. go to next card of bkgnd bkgndName
  188. get the short name of this card
  189. put it into cardName
  190. add 1 to theCount
  191. end repeat
  192. set the lockscreen to false
  193. return theCount
  194. end cardsInBkgnd
  195.  
  196. on idle
  197. global menu1,menu2,lastTick
  198. if (the ticks-lastTick)>120 then
  199. put the ticks into lastTick
  200. ShowMenu(menu1)
  201. ShowMenu(menu2)
  202. end if
  203. pass idle
  204. end idle
  205.  
  206. on doMenu which
  207. global menu1,menu2,answer
  208. global scriptMode,voice,firstCopyCardPrompt
  209. global modifier,modifierButton,note,duration
  210. global whichNote,firstNote,secondNote,scale
  211. if which is "Play this script" then
  212. send playScript to card "piano keyboard"
  213. exit doMenu
  214. else if which is "Play selection" then
  215. send playSelection to card "piano keyboard"
  216. exit doMenu
  217. else if which is "Play last line" then
  218. send playLine to card "piano keyboard"
  219. exit doMenu
  220. else if which is "Stop playing" then
  221. play stop
  222. exit doMenu
  223. else if which is "New script‚Ķ" then
  224. answer "Save to file before erasing current script?" with¬¨
  225. "Erase" or "Cancel" or "Save"
  226. if it is "Cancel" then exit doMenu
  227. if it is "Save" then
  228. send saveScript to card "piano keyboard"
  229. go to card "piano keyboard"
  230. end if
  231. put empty into card field "ScriptWindow"
  232. exit doMenu
  233. else if which is "Erase this script" then
  234. put empty into card field "ScriptWindow"
  235. exit doMenu
  236. else if which is "Save to file‚Ķ" then
  237. send saveScript to card "piano keyboard"
  238. if answer <> "Oops" then buildGoToFileMenu
  239. go to card "piano keyboard"
  240. exit doMenu
  241. else if which is "Chromatic Scale‚Ķ" then
  242. put "The first note is" into whichNote
  243. put "Select the first note for the scale." into ¬¨
  244. line 2 of card field "headerPrompt"
  245. set the visible of card field "headerPrompt" to true
  246. findNote
  247. if note <> "Not a note button" then
  248. put note into firstNote
  249. else
  250. set the visible of card field "headerPrompt" to false
  251. exit doMenu
  252. end if
  253. put "The last note is" into whichNote
  254. put "Select the last note for the scale." into ¬¨
  255. line 2 of card field "headerPrompt"
  256. findNote
  257. if note <> "Not a note button" then
  258. put note into secondNote
  259. else
  260. set the visible of card field "headerPrompt" to false
  261. exit doMenu
  262. end if
  263. put "Scale under construction." into line 2 of card field "headerPrompt"
  264. if secondNote > firstNote then
  265. upScale
  266. else
  267. downScale
  268. end if
  269. put quote after scale
  270. do scale
  271. put empty into card field "headerPrompt"
  272. set the visible of card field "headerPrompt" to false
  273. exit doMenu
  274. else if which is "Start New Line" then
  275. put "newLine" into scriptMode
  276. exit doMenu
  277. else if which is "Insert Empty Line" then
  278. put "--"&return after card field "scriptWindow"
  279. put "newLine" into scriptMode
  280. exit doMenu
  281. else if which is "Erase Last Line" then
  282. delete last line of card field "scriptWindow"
  283. put "newLine" into scriptMode
  284. exit doMenu
  285. end if                                         -- end menu1 handler
  286. --                                           menu2 go to saved file
  287. global cardCount,stackName
  288. if the name of this stack is stackName then
  289. repeat with i = 1 to cardCount - 1
  290. get the short name of card i + 1 of bkgnd "SavedScriptsBkgnd"
  291. if which = it then
  292. send enableMenusFalse to card "piano keyboard"
  293. go to card it
  294. exit doMenu
  295. end if
  296. end repeat                                 -- end menu2 handler
  297. end if
  298.  
  299. if which is "Paste Card" then
  300. if firstCopyCardPrompt = true or firstCopyCardPrompt = empty then
  301. beep
  302. answer "Duplicate card names might cause crashes!!"¬¨
  303. with "That‚Äôs OK" or "Cancel"
  304. if it is "Cancel" then exit doMenu
  305. put false into firstCopyCardPrompt
  306. end if
  307. if firstCopyCardPrompt = false then
  308. send "doMenu Paste Card" to HyperCard
  309. beep
  310. set the cursor to 4
  311. put "WARNING: Duplicate card names might cause crashes or other problems!!"
  312. put item 1 of the rect of the msg box into MsgH
  313. put item 2 of the rect of the msg box into MsgV
  314. repeat until abs(MsgV - 150) < 5
  315. if MsgV < 150 then
  316. add (150 - MsgV) div 5 to MsgV
  317. else
  318. subtract (MsgV - 150) div 5 from MsgV
  319. end if
  320. if abs(MsgH - 20) > 1 then
  321. if MsgH < 20 then
  322. add (20 - MsgH) div 2 to MsgH
  323. else
  324. subtract (MsgH - 20) div 2 from MsgH
  325. end if
  326. end if
  327. show msg at MsgH,MsgV
  328. end repeat
  329. exit doMenu
  330. end if
  331. end if
  332. pass doMenu
  333. end doMenu
  334.  
  335. on findNote
  336. global scriptMode,note,whichNote
  337. put "newLine" into scriptMode
  338. wait until the mouse is down
  339. put the mouseLoc into mouseDownLoc
  340. wait until the mouse is up
  341. put "One moment please‚Ķ" into line 2 of card field "headerPrompt"
  342. put the mouseLoc into mouseUpLoc
  343. put item 1 of mouseDownLoc into Hd
  344. put item 2 of mouseDownLoc into Vd
  345. put item 1 of mouseUpLoc into Hu
  346. put item 2 of mouseUpLoc into Vu
  347. put item 1 of the rect of card button id 236 into L
  348. put item 2 of the rect of card button id 236 into T
  349. put item 3 of the rect of card button id 319 into R
  350. put item 4 of the rect of card button id 236 into B
  351. if Hu > L and Hu < R and Vu > T and Vu < B and¬¨
  352. Hd > L and Hd < R and Vd > T and Vd < B then
  353. drag from mouseDownLoc to mouseUpLoc
  354. put last word of last line of card field "scriptWindow" into note
  355. delete char 1 of note
  356. delete last char of note
  357. delete last char of note
  358. put whichNote&&note into line 2 of card field "headerPrompt"
  359. delete last line of card field "scriptWindow"
  360. put the id of card button note into buttonID
  361. if buttonID >235 and buttonID < 320 then
  362. put buttonID - 212 into note
  363. else
  364. beep
  365. answer "Not a note button"
  366. put "Not a note button" into note
  367. end if
  368. else
  369. beep
  370. answer "Not a note button"
  371. put "Not a note button" into note
  372. end if
  373. end fin